/*=+--+=#=+--      UAS Severe Weather Simulation Softeware        --+=#=+--+=#*\
|          Copyright (C) 2013 Regents of the University of Colorado.           |
|                             All Rights Reserved.                             |
                                                                                
     This program is free software: you can redistribute it and/or modify       
     it under the terms of the GNU General Public License version 2 as          
     published by the Free Software Foundation.                                 
                                                                                
     This program is distributed in the hope that it will be useful,            
     but WITHOUT ANY WARRANTY; without even the implied warranty of             
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
     GNU General Public License for more details.                               
                                                                                
     You should have received a copy of the GNU General Public License          
     along with this program.  If not, see <http://www.gnu.org/licenses/>.      
                                                                                
            Jack Elston                           Cory Dixon                    
|           elstonj@colorado.edu                  dixonc@colorado.edu          |
|                                                                              |
\*=+--+=#=+--                 --+=#=+--+=#=+--                    --+=#=+--+=#*/
/***********************************************************************
 * FILENAME:
 * String.h
 *
 * PURPOSE:
 * Implements a C++ string class, and does most
 * of the operations one might expect a good string
 * class to do.
 *
 * CREATED:
 * 11/2000 by Cory Dixon
 *
 * LAST MODIFIED:
 * $Author: dixonc $
 * $Date: 2005/07/13 21:00:06 $
 * $Revision: 1.2 $
 *
 ***********************************************************************/

#ifndef _SSTRING_H
#define _SSTRING_H

// includes
#include <iostream>
#include <string>
#include <stdlib.h>
#include <string.h>

using namespace std;

// Maximum istream characters read per line
#define STRING_MAX_ISTREAM_BUF 256

class String
{
	private:
		char *   str;
		size_t   len;

	public:

		String  (const char * s);
		String  (const String & st);
		String  ();
		~String ();

		size_t length () const { return len; }
		char * c_str () const { return str; }
		char operator () (size_t ind) const { return ( len > ind ? str[ind] : '\0' ); }

		// overloaded operators assignment operators
		String & operator  =  (const String & st); 
		String & operator  =  (const char * s);
		String & operator += (const String & st);
		String & operator += (const char * s);

		// string manipulation
		void toupper();
		void tolower();
		int find(const String & st);
		int find(const char *s);

		// friends
		friend bool operator  >  (const String & st1, const String & st2);
		friend bool operator  <  (const String & st1, const String & st2);
		friend bool operator == (const String & st1, const String & st2);
		friend bool operator == (const String & st1, const char * st2);
		friend bool operator == (const char * st1, const String & st2);
		friend bool operator != (const String & st1, const String & st2);
		friend bool operator != (const String & st1, const char *st2);
		friend bool operator != (const char * st1, const String & st2);
		friend ostream & operator << (ostream & os, const String & st);
		friend istream & operator >> (istream & is, String & st);
		friend String operator  + (const String & s1, const String & s2);
		friend String operator  + (const String & s1, const char * s2);
		friend String operator  + (const char * s1, const String & s2);
};

#endif  // _SSTRING_H

